package com.biz.primus.ms.commodity.trans;

import com.biz.primus.ms.commodity.dao.po.ProductCascadeItem;
import com.biz.primus.ms.commodity.dao.ro.ProductCascadeItemRo;
import com.google.common.base.Function;
import javax.annotation.Nullable;


/**
 * Created by aaa on 2017/6/17.
 */
public class ProductCascadeItem2ProductCascadeItemRo implements Function<ProductCascadeItem, ProductCascadeItemRo> {

    @Nullable
    @Override
    public ProductCascadeItemRo apply(@Nullable ProductCascadeItem input) {
        ProductCascadeItemRo resp = new ProductCascadeItemRo();
        resp.setId(input.getId());
        resp.setCreateTimestamp(input.getCreateTimestamp());
        if(input.getProduct() != null){
            resp.setProductId(input.getProduct().getId());
        }
        resp.setValue(input.getValue());
        if(input.getProductCascade() != null){
            resp.setProductCascadeId(input.getProductCascade().getId());
            resp.setBeCascadeProductId(input.getProductCascade().getGlProduct().getId());
        }
        return resp;
    }
}
